package com.smashcrush.server.rest;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.smashcrush.model.Script;
import com.smashcrush.server.service.ScriptService;


@Controller
@Path("/api/script")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class ScriptResource {

	@Autowired
	ScriptService scriptService;

	@POST
	@Path("token/{token}/saveScript")
	public String saveScript(@PathParam("token") String token, Script script) {
		return scriptService.saveScript(token, script);
	}

	@POST
	@Path("token/{token}/getScripts")
	public List<Script> getScripts(@PathParam("token") String token) {
		return scriptService.getScripts(token);
	}

}